package ldk.app.kotlinweibo.apis

import android.content.Context
import android.view.View
import android.widget.Toast
import java.lang.ref.WeakReference

/**
 * Created by ldkxingzhe@163.com on 2017/6/29.
 */
object APIErrorCommon {
    private var lastToast: WeakReference<Toast>? = null

    fun toastMessage(context: Context, message: String?){
        var lastToast = this.lastToast?.get()
        if (lastToast != null && lastToast.view.windowVisibility == View.VISIBLE){
            lastToast.cancel()
        }
        Toast.makeText(context, message, Toast.LENGTH_SHORT).show()
    }
}